package com.heima.comment.controller;

import com.heima.comment.service.CommentRepayService;
import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment_repay")
@Api("评论回复接口")
///api/v1/comment_repay/like
public class ReplayCommentController {
    @Autowired
    private CommentRepayService commentRepayService;
    /**
     * 保存评论
     * @param dto
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存评论",tags = "保存评论")
    public ResponseResult saveReplayComment(@RequestBody  @Validated CommentRepaySaveDTO dto){
        return commentRepayService.saveCommentRepay(dto);

    }

    /**
     * 评论点赞
     * @param dto
     * @return
     */
    @PostMapping("/like")
    @ApiOperation(value = "回复列表点赞",tags = "回复列表点赞")
    public ResponseResult likeReplayComment(@RequestBody  @Validated CommentRepayLikeDTO dto){
        return commentRepayService.saveCommentRepayLike(dto);
    }

    ///api/v1/comment/load

    /**
     * 评论回复列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation(value = "评论回复列表加载",tags = "评论回复列表加载")
    public ResponseResult loadReplayCommentList(@RequestBody  @Validated CommentRepayDTO dto){
        return commentRepayService.loadCommentRepay(dto);
    }
}
